/**
 * Copyright (c) 2009 blurredVision
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or 
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 
 * OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
#ifndef __IJUKEBOX_H__
#define __IJUKEBOX_H__

#pragma once

#include <map>
#include <string>
#include "ISound.h"


namespace audio{

	enum {
		JB_NORMAL = 0,
		JB_PLAY_SINGLE = 1,
		JB_LOOP_ONE = 2,
		JB_LOOP_PLAYLIST = 3,
		JB_INTRO_LOOP = 4,
		JB_LOOP_VARIATIONS = 5,
	};

/**
 *	Class set manages the music-playing 
 *
 * \ingroup CoreEngine
 *
 *
 * \par requirements
 * win98 or later\n
 * win2k or later\n
 * MFC\n
 *
 * \version 1.0
 * first version
 *
 * \date 10-18-2007
 *
 * \author dennis
 *  
 * \todo
 *
 * \bug 
 *
 */
class DLL_EXPORT IJukeBox
{
public:
	IJukeBox(void);
	
	/**
	*	Start the JukeBox
	*/
	virtual void play()=0;

	/**
	*	Start the sound by fading in.
	*	\param float fFadeTime
	*/
	virtual void play_fadeIn(float fFadeTime)=0;

	/**
	*	Stop the JukeBox immediatly
	*/
	virtual void stop()=0;

	/**
	*	Fade the music out and stop
	*	\param float fFadeTime;
	*/
	virtual void fadeAndStop(float fFadeTime)=0;

	/**
	*	Set the song to start with by playlist number
	*/
	virtual void setCurrentSong(int _number)=0;

	/**
	*	Set the song to start with by filename (without path)
	*/
	virtual void setCurrentSong(const std::string &_filename)=0;

	/**
	*	Return the playlist number of the current song 
	*/
	virtual int getCurrentSong()=0;

	/**
	*	Skip to next song
	*/
	virtual void nextSong(float _fadeTime)=0;

	/**
	*	Skip to previous song
	*/
	virtual void previousSong(float _fadeTime)=0;
	
	/**
	*	Add a soundfile to the playlist.
	*	Soundfiles are NOT added twice.
	*	
	*	\param std::string _fileName Name of Soundfile
	*	\return int Song number in playlist or -1 (error)
	*	!!! At the moment only ogg-files are supported !!!
	*/
	virtual int addToPlaylist(const std::string &_fileName)=0;
	
	/**
	*	Remove a soundfile from playlist
	*	All used resources are freed
	*	\param std::string 
	*/
	virtual void removeFromPlaylist(const std::string &_fileName)=0;
	
	//void removeFromPlaylist(int index);

	/**
	*	Set to true if you want to play the playlist
	*	in random order
	*	\param bool
	*/
	virtual void setRandom(bool _val);

	/**
	*	Standard update-method.
	*	Used for doing some shit.
	*	Call once per frame
	*/
	virtual void update(const double &dt)=0;

	/**
	*	Set the overall volume for the JukeBox	
	*/
	virtual void setVolume(float _vol)=0;

	/**
	*	Set the play mode of the JukeBox:
	*	JB_NORMAL:
	*		Start with current and stop at the end of the playlist
	*	JB_PLAY_SINLGE:
	*		Play current song and stop
	*	JB_LOOP_ONE:
	*		Play current song in loop		
	*	JB_LOOP_PLAYLIST:
	*		Start at current song and repeat the playlist in a loop
	*	JB_INTRO_LOOP:
	*		Start with current song and loop the following. Useful for
	*		playing loops with an introsound	
	*	JB_LOOP_VARIATIONS:
	*		Play a base loop in circle and randomly alternate with loop variations.
	*		All loops should have the same length
	*/
	virtual void setPlayMode(int _playmode);

	/**
	*	Set intro and loop track for mode JB_INTRO_LOOP
	*	Should always be called before play
	*/
	virtual void setIntroAndLoop(unsigned int _intro, unsigned int _loop)=0;

	/**
	*	\param unsigned int		_blRepeat Number of cycles the base loop
	*							is played inbetween the variations. Default is 1.
	*/
	virtual void setUpLoopVariations(unsigned int _blRepeat)=0;

protected:
	virtual ~IJukeBox(void);	
	
	bool m_bRandomPlay;		///< Play soundFiles in random
	int m_iPlaymode;		///< Play mode of the JukeBox
	
	float m_fVolume;		///< The volume of the JukeBox
};

} //namespace audio

#endif // __IJUKEBOX_H__
